import Vue from 'vue'
import Vuex from 'vuex'
import {newsClassList} from "../api/api";

// 新加
import login from "./module/login"
import collect from "./module/collect";

import { Toast } from 'vant';
Vuex.Store.prototype.$toast = Toast;
Vue.use(Vuex)

export default new Vuex.Store({
    state: {
        //新闻列表分类数组
        newsList: [],

    },
    mutations: {
        //改变新闻列表分类数组的方法
        changenewsList(state, newsList) {
            state.newsList = newsList
        },

    },
    actions: {
        //新闻列表分类
        initnewsList(context) {
            newsClassList(0, 10).then(res => {
                console.log(res)
                context.commit("changenewsList", res.rows)
            })
        },


    },
    modules: {
        login,
        collect
    }
})
